
package com.test.junit;

import javax.annotation.PostConstruct;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

/**
 * 带事务的测试基类
 *
 */
/**
 * @author jjb
 * @date 2018/08/06
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:config/spring/applicationContext-spring.xml"})
public class MyJunitTransactionalTestBase extends AbstractTransactionalJUnit4SpringContextTests {
    @Autowired
    protected WebApplicationContext wac;

    protected MockMvc mockMvc;

    @PostConstruct
    public void setUp() throws Exception {
        // 初始化MockMvc对象
        mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();

    }
}
